/**
 * Created by lenovo on 2015/8/24.
 */
$(function(){
    var content;
    /*$("#content tr:odd").css("background-color","#D2B48C");
    $("#content tr:even").css("background-color","#C0C0C0");*/
    $('.aa').click(function(){
        var clickObj = $(this);
        content = clickObj.html();
        //alert(clickObj.id);
        changeToEdit(clickObj);
    });
    function changeToEdit(node){
        node.html("");
        var inputObj = $("<input type='text'/>");
        inputObj.css("border","0").css("background-color",node.css("background-color"))
            .css("font-size",node.css("font-size")).css("height","20px")
            .css("width",node.css("width")).val(content).appendTo(node)
            .get(0).select();
        inputObj.click(function(){
            return false;
        }).keyup(function(event){
            var keyvalue = event.which;
            if(keyvalue==13){
                node.html(node.children("input").val());
            }
            if(keyvalue==27){
                node.html(content);
            }
        })/*.blur(function(){
            if(node.children("input").val()!=content){
                if(confirm("是否保存修改的内容？","Yes","No")){
                    node.html(node.children("input").val());
                }else{
                    node.html(content);
                }
            }else{
                node.html(content);
            }
        });*/
    }
    $('.update').click(function(){
        var clickobj2=$("#aaa");
        if(clickobj2.children("input").val()!=content){
            if(confirm("是否保存修改的内容？","Yes","No")){
                clickobj2.children.html(node.children("input").val());
            }else{
                clickobj2.children.html(content);
            }
        }else{
            clickobj2.children.html(content);
        }
    })
});
